package ryrpc

import (
	"github.com/doug-martin/goqu/v9"
)

type SelectParam struct {
	TableName      string      `json:"table_name" cron:"table_name"`
	Record         interface{} `json:"record" cron:"record"`
	Data           interface{} `json:"data" cron:"data"`
	QueryCondition goqu.Ex     `json:"query_condition" cron:"query_condition"`
	OperateRedis   bool        `json:"operate_redis" cron:"operate_redis"`
	RedisKey       string      `json:"redis_key" cron:"redis_key"`
}

func RpcQuery(param SelectParam) (interface{}, error) {

	var data interface{}

	err := client.Call("/member/query", param, &data)
	if err != nil {
		return data, err
	}
	return data, nil
}

func RpcUpdate(param SelectParam) (interface{}, error) {

	var data interface{}

	err := client.Call("/member/update", param, &data)
	if err != nil {
		return data, err
	}
	return data, nil
}

func RpcInsert(param SelectParam) (interface{}, error) {

	var data interface{}

	err := client.Call("/member/insert", param, &data)
	if err != nil {
		return data, err
	}
	return data, nil
}

func RpcDelete(param SelectParam) (interface{}, error) {

	var data interface{}

	err := client.Call("/member/delete", param, &data)
	if err != nil {
		return data, err
	}
	return data, nil
}
